#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; array tool


; M(A_Cat(A(1,2,3)))
A(args*) {  ; 不定参数 2 数组
    If (args.Length() == 1) {
        args := args[1]
    }

    ar := Object()
    For i,e In args {
        ar.Insert(e)
    }

    Return ar
}



A_Cat(ar, split="`n") {  ; concat array 2 string
    If(ar.Length() == 0) {
        Return
    }

    If(ar.Length() == 1) {
        Return ar[1]
    }

    index := 1
    str := ar[index]

    while(++index <= ar.Length()) {
        str := str split ar[index]
    }

    Return str
}



A_Line(ar) {  ; concat array 2 line
    Return A_Cat(ar, "")
}



A_Sub(ar, start, end:=0) {  ; array index begin with 1
    If(end == 0) {
        end := ar.Length()
    }

    A_Sub := []
    While(start <= end) {
        A_Sub.Insert(ar[start])
        ++start
    }
    Return A_Sub
}



A_Rever(ar) {  ; reverse array
    A_Rever := []
    len := ar.Length()
    While(len >= 1){
        A_Rever.Insert(ar[len])
        --len
    }
    Return A_Rever
}
